package com.ruoyi.web.controller.charge;

import com.ruoyi.charge.service.ChargeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.doctor.domain.DoctorPatient;
import com.ruoyi.pssd.domain.PsdDrug;
import com.ruoyi.system.domain.SysCheck;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("charge/charge")
public class ChargeController extends BaseController {
    @Autowired
    private ChargeService chargeService;

    @PreAuthorize("@ss.hasPermi('charge:patient:get')")
    @GetMapping("patient")
    public DoctorPatient get(String registerNumber) {
        return chargeService.getPatientByRegisterId(registerNumber);
    }

    @PreAuthorize("@ss.hasPermi('charge:patient:getpres')")
    @GetMapping("pres")
    public TableDataInfo getPres(@RequestParam(defaultValue = "0") Integer patientId) {
        List<PsdDrug> drugs = chargeService.getDrugsById(patientId);
        List<SysCheck> checks = chargeService.getChecksById(patientId);
        List<Object> objects = new ArrayList<>();
        objects.add(drugs);
        objects.add(checks);
        return getDataTable(objects);
    }


}
